﻿using System;
using System.Windows.Data;
using Kiva7.DataClasses;
using Kiva7.Translations;

namespace Kiva7.ValueConverter
{
    public class LoanStatusConverter : IValueConverter
    {
        public object Convert(object value,
                              Type targetType,
                              object parameter,
                              System.Globalization.CultureInfo culture)
        {
            if (value is LoanStatus)
            {
                LoanStatus status = (LoanStatus) value;
                if (status == LoanStatus.Defaulted)
                {
                    return AppResources.Defaulted;
                }
                if (status == LoanStatus.Funded)
                {
                    return AppResources.Funded;
                }
                if (status == LoanStatus.Fundraising)
                {
                    return AppResources.Fundraising;
                }
                if (status == LoanStatus.InRepayment)
                {
                    return AppResources.InRepayment;
                }
                if (status == LoanStatus.Paid)
                {
                    return AppResources.Paid;
                }
                if (status == LoanStatus.Refunded)
                {
                    return AppResources.Refunded;
                }
                if (status == LoanStatus.Expired)
                {
                    return AppResources.Expired;
                }
                return status.ToString();
            }
            return value;
        }

        public object ConvertBack(object value,
                                  Type targetType,
                                  object parameter,
                                  System.Globalization.CultureInfo culture)
        {
            return value;
        }
    }
}